import request from '@/utils/request'

/**
 * 图片上传
 * @param files
 * @returns {Promise<unknown>}
 */
export const uploadImage = (files) => {
  // 文件上传大小, 2M
  const maxSize = 1024 * 1024 * 2
  // 执行上传
  return new Promise((resolve, reject) => {
    request.urlFileUpload({ files, maxSize })
      .then(result => resolve(result))
      .catch(reject)
  })
}

/**
 * 视频上传
 * @param files
 * @returns {Promise<unknown>}
 */
export const uploadVideo = (files) => {
  // 文件上传大小, 3M
  const maxSize = 1024 * 1024 * 3
  // 执行上传
  return new Promise((resolve, reject) => {
    request.urlFileUpload({ url: '/store/files/video/upload', files, maxSize })
      .then(result => resolve(result))
      .catch(reject)
  })
}
